<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/html">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <script type="text/javascript" src="__PUBLIC__jedate/jedate.js"></script>
    <include file="./Public/Admin/header.html" />
    <style>
        .form-horizontal .control-group {
            margin-bottom: 10px;
        }
        .input-medium {
            width: 480px;
        }
        input {
            width: 450px;
        }
        .datainp{ width:200px; height:40px; border:1px #ccc solid;}
        .datep{ margin-bottom:40px;}
    </style>

</head>
<body>
<div id="main">
    <div class="container-fluid">

        <div class="row-fluid">
            <div class="span12">
                <div class="box">
                    <div class="box-title">
                        <div class="span10">
                            <?php if($_GET['action'] == 'add'):?>
                            <h3><i class="icon-edit"></i>课程添加</h3>
                            <?php else:?>
                            <h3><i class="icon-edit"></i>课程编辑</h3>
                            <?php endif;?>
                        </div>
                        <div class="span2"><a class="btn" href="javascript:void(0)" onclick="javascript:window.history.go(-1)">返回</a></div>
                    </div>

                    <div class="box-content">
                        <form action="{:U('edit')}" method="post" class="form-horizontal form-validate">

                            <div class="control-group">
                                <label for="name" class="control-label">课程名称：</label>
                                <div class="controls">
                                    <input type="text" name="name" id="name" class="input-medium" value="<?php echo $info['name']; ?>" data-rule-required="true" /><span class="maroon">*</span>
                                </div>
                            </div>
                            <div class="control-group">
                                <label for="images" class="control-label">课程图片：</label>
                                <div class="controls">
                                    <button type="button" class="btn" onClick="upImage('banner_img');"><i class=" icon-upload"></i> 上传</button> <span class="maroon">*图案片大小277*160</span><br/><br/>
                                    <img src="{$info['images']}" id="show_img" width="255" style="width:120px;"/>
                                    <input type="hidden" name="images" id="images" value="<?php echo $info['images']; ?>" data-rule-required="true" />
                                </div>
                            </div>
                            <div class="control-group">
                                <label for="money" class="control-label">报名费：</label>
                                <div class="controls">
                                    <input type="number" name="money" id="money" class="input-medium" value="<?php echo $info['money'];?>" data-rule-required="true" /><span class="maroon">*请输入数字</span>
                                </div>
                            </div>

                            <div class="control-group">
                                <label for="stages" class="control-label">期数：</label>
                                <div class="controls">
                                    <input type="number" name="stages" id="stages" class="input-medium" value="<?php echo $info['stages'];?>" data-rule-required="true" /><span class="maroon">*请输入数字</span>
                                </div>
                            </div>
                            <div class="control-group">
                                <label for="startime" class="control-label">开课时间：</label>
                                <div class="controls">
                                    <input class="datainp" name="startime" id="startime" type="text" placeholder="请选择" value="{$info.startime}"  readonly>
                                </div>
                            </div>
                            <div class="control-group">
                                <label for="endtime" class="control-label">结课时间：</label>
                                <div class="controls">
                                    <input class="datainp" name="endtime" id="endtime" type="text" placeholder="请选择" value="{$info.endtime}"  readonly>
                                </div>
                            </div>
                            <div class="control-group">
                                <label for="type" class="control-label">课程分类：</label>
                                <div class="controls">
                                    <select name="type" id="type">
                                        <volist name="types" id="type">
                                            <option value="{$type.id}">{$type.name}</option>
                                        </volist>
                                    </select>

                                </div>
                            </div>


                            <div class="control-group">
                                <label for="value" class="control-label">课程介绍：</label>
                                <div class="controls">
                                    <textarea name="value" style="width:80%;" id="value" class="input-medium" ><?php echo $info['value'];?></textarea>
                                </div>
                            </div>

                            <div class="form-actions">
                                <input type="hidden" name="id" id="id" value="<?php echo $info['id']; ?>"/>
                                <input type="hidden" name="action" id="action" value="<?php echo $_GET['action']?>"/>
                                <button type="button" class="btn btn-primary" id="btnsave">保存</button>

                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>


<script type="text/javascript">
    jeDate({
        dateCell:"#startime",
        format:"YYYY-MM-DD hh:mm:ss",
        isinitVal:true,
        isTime:true, //isClear:false,
        minDate:"2014-09-19 00:00:00",
        okfun:function(val){alert(val)}
    })
    jeDate({
        dateCell:"#endtime",
        format:"YYYY-MM-DD hh:mm:ss",
        isinitVal:true,
        isTime:true, //isClear:false,
        minDate:"2014-09-19 00:00:00",
        okfun:function(val){alert(val)}
    })
</script>
<script type="text/javascript">
    $("#btnsave").click(function(){
        var share_img = $("#images").val();
        if(share_img == ''){
            G.ui.tips.err('请上传课程图片');
            return false;
        }
        $("#btnsave").submit();
    });
</script>
<script type="text/javascript" charset="utf-8" src="__APP__/Public/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__APP__/Public/ueditor/ueditor.all.js"></script>

<script type="text/javascript">
    //设置编辑器参数
    var param="user_name=<?php echo $sysuser['user_name']?>";
    var options = {
        initialFrameWidth:700,
        initialFrameHeight: 200,
        imageUrl:window.UEDITOR_CONFIG.UEDITOR_HOME_URL+"php/imageUp.php?"+param,
        fileUrl:window.UEDITOR_CONFIG.UEDITOR_HOME_URL+"php/fileUp.php?"+param,
        imageManagerUrl:window.UEDITOR_CONFIG.UEDITOR_HOME_URL + "php/imageManager.php?"+param,
        toolbars:[
            [ 'source', '|', 'undo', 'redo', '|',
                'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist',  '|',

                'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                'indent',
                'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|',
                'link', 'unlink', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                'insertimage', 'emotion',  'horizontal','|','help']
        ]
    };
    var ue = UE.getEditor('kjieshao', options);
    var ue = UE.getEditor('value', options);
</script>
<script type="text/plain" id="upload_ue" style="display: none;"></script>
<script type="text/javascript">

    var typeid='';
    //重新实例化一个编辑器，防止在上面的editor编辑器中显示上传的图片或者文件
    var _editor = UE.getEditor('upload_ue',options);
    _editor.ready(function () {
        //设置编辑器不可用
        _editor.setDisabled();
        //隐藏编辑器，因为不会用到这个编辑器实例，所以要隐藏
        _editor.hide();
        //侦听图片上传
        _editor.addListener('beforeInsertImage', function (t, arg) {
            //将地址赋值给相应的input,只去第一张图片的路径
            imgurl=arg[0].src;
            $("#images").val(imgurl);
            $("#show_img").attr("src",imgurl);
        })

        //侦听文件上传，取上传文件列表中第一个上传的文件的路径
        _editor.addListener('afterUpfile', function (t, arg) {
            $("#file").attr("value", _editor.options.filePath + arg[0].url);
        })
    });
    //弹出图片上传的对话框
    function upImage(type) {
        typeid=type
        var myImage = _editor.getDialog("insertimage");
        myImage.open();
    }
    //弹出文件上传的对话框
    function upFiles() {
        var myFiles = _editor.getDialog("attachment");
        myFiles.open();
    }
</script>
</body>
</html>
